__author__ = 'Forcs'

import hashlib

def format_value(value, unit=10000.0, unit_name='w'):
    if value > unit:
        return ('%.1f' + unit_name) % (value / unit)
    else:
        return int(value)

def md5(txt):
    m = hashlib.md5()
    m.update(txt)
    return m.hexdigest()


def generate_appkey(app_code, app_name, app_pkg, date_added):
    s = "{}|{}-{}@{:x}".format(app_code, app_name, app_pkg, date_added)
    return md5(s)
